package com.team.ai.service;

import com.team.ai.entity.*;
import com.team.ai.mapper.CategoryVideoMapper;
import com.team.ai.mapper.PaperMapper;
import com.team.ai.mapper.QuestionMapper;
import com.team.ai.mapper.StuVideoMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.LinkedList;
import java.util.List;

@Transactional
@Service
public class CategoryService {
    @Resource
    StuVideoMapper stuVideoMapper;
    @Resource
    CategoryVideoMapper categoryVideoMapper;
    public String selectCategory(String category){
        try{
            List<CategoryVideo> categorys = categoryVideoMapper.selectCategory(category);
            List<StuVideo> stuVideos = new LinkedList<>();
            for (int i = 0; i < categorys.size(); i++) {
                stuVideos.add(stuVideoMapper.selectDetail(categorys.get(i).getStuid()));
            }
            return ResultEntity.success(stuVideos) ;
        }catch (Exception e){
            e.printStackTrace();
            return  ResultEntity.fail(-10005);
        }
    }
}
